﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Cabal.Kernel.DataSet;

namespace test
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        CabalLinq dataset; // = new CabalLinq();
        Cabal.Kernel.Output.Mission mission = new Cabal.Kernel.Output.Mission(null,null);
        Cabal.Kernel.Output.MissionData data;

        private void Form1_Load(object sender, EventArgs e)
        {
            data = new MDataTest();
            dataset = data.FlagSet;

            //dataset 
            foreach (string i in txtSource.Lines)
            {
                dataset.AddData(i);
            }
        }


        private void button2_Click(object sender, EventArgs e)
        {
            txtOut.AppendText(dataset.Select(txtExp.Text).ToString());
            txtOut.AppendText("\r\n");
        }

        private void button3_Click(object sender, EventArgs e)
        {
            txtOut.AppendText(dataset.GetValue(txtExp.Text));
            txtOut.AppendText("\r\n");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            txtOut.AppendText(data.SelectExp(txtExps.Lines).ToString());
            txtOut.AppendText("\r\n");
        }

        
        private void button5_Click(object sender, EventArgs e)
        {
            mission.Owner = new Cabal.Kernel.Output.MissionOwner();
            mission.Owner.Add(new Cabal.Kernel.Output.MissionReference(new Cabal.Kernel.Output.MissionNoticeCallback(callback)));
            mission.Owner.Add(new Cabal.Kernel.Output.MissionReference(new Cabal.Kernel.Output.MissionNoticeCallback(callback)));
            mission.Owner.Add(new Cabal.Kernel.Output.MissionReference(new Cabal.Kernel.Output.MissionNoticeCallback(callback)));
        }

        bool callback(object sender,Cabal.Kernel.Output.MissionEventArgs e)
        {
            MessageBox.Show("notice!");
            return false;
        }

        private void button4_Click(object sender, EventArgs e)
        {
            mission.Owner.StartNotice(null, null);
        }

    }

    class MDataTest : Cabal.Kernel.Output.MissionData
    {
        public override string GetMissionType()
        {
            throw new NotImplementedException();
        }

        public override object GetResult()
        {
            throw new NotImplementedException();
        }

        public override object DoWork()
        {
            throw new NotImplementedException();
        }

        public override bool NeedCollect(int time)
        {
            throw new NotImplementedException();
        }
    }
}
